export function validateMobile (rule, value, callback) {
  const passRegexp = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
  if (value === '' || value === undefined || value === null) {
    callback()
  } else if (passRegexp.test(value)) callback()
  else callback(new Error('手机号码格式错误'))
}

export function validatePassword (rule, value, callback) {
  const passRegexp = /^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$)([^\u4e00-\u9fa5\s]){6,20}$/
  if (value === '' || value === undefined || value === null) {
    // 检查是否为空
    callback(new Error('请输入密码'))
  } else if (passRegexp.test(value)) callback()
  else callback(new Error('由6-15位字母|数字|符号(除空格)组成,至少两种类型'))
}

export function validateSmsCode (rule, value, callback) {
  const passRegexp = /^\d{4}$/
  if (value === '' || value === undefined || value === null) {
    // 检查是否为空
    callback(new Error('请输入验证码'))
  } else if (passRegexp.test(value)) callback()
  else callback(new Error('验证码错误'))
}

export function validateMobileOhter (rule, value, callback) {
  const passRegexp = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
  if (value === '' || value === undefined || value === null) {
    callback(new Error('请输入手机号'))
  } else if (passRegexp.test(value)) callback()
  else callback(new Error('手机号码格式错误'))
}
